//
//  ViewController.m
//  DotNetForApi
//
//  Created by weihong xuan on 2018/1/30.
//  Copyright © 2018年 weihong xuan. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton * apiBtnGoodsList = [[UIButton alloc]initWithFrame:CGRectMake(20, 100, 150, 30)];
    apiBtnGoodsList.backgroundColor = [UIColor cyanColor];
    [apiBtnGoodsList setTitle:@"接口GoodsList" forState:(UIControlStateNormal)];
    [apiBtnGoodsList addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    apiBtnGoodsList.tag = 101;
    [self.view addSubview:apiBtnGoodsList];

    UIButton * apiBtnOrderList = [[UIButton alloc]initWithFrame:CGRectMake(200, 100, 150, 30)];
    apiBtnOrderList.backgroundColor = [UIColor cyanColor];
    [apiBtnOrderList setTitle:@"接口OrderList" forState:(UIControlStateNormal)];
    [apiBtnOrderList addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    apiBtnOrderList.tag = 102;
    [self.view addSubview:apiBtnOrderList];
    
    UIButton * apiBtnLogin = [[UIButton alloc]initWithFrame:CGRectMake(20, 200, 150, 30)];
    apiBtnLogin.backgroundColor = [UIColor cyanColor];
    [apiBtnLogin setTitle:@"接口post Login" forState:(UIControlStateNormal)];
    [apiBtnLogin addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    apiBtnLogin.tag = 103;
    [self.view addSubview:apiBtnLogin];
}

-(void)btnClick:(UIButton*)getBtn{
    if (getBtn.tag == 101) {
        [HttpClient get_indexNew_action:Url_GetGoodsList withid:@"222" withName:@"小猫" success:^(id responseObject) {
            
            NSLog(@"请求的数据：%@",responseObject);
            
        } fail:^(NSString *error) {
            
            NSLog(@"错误：%@",error);
            
        }];
    }
    else if (getBtn.tag == 102){
        [HttpClient get_OrderList_action:Url_GetOrderList withuid:@"111" success:^(id responseObject) {
            
            NSLog(@"请求的数据：%@",responseObject);
            
        } fail:^(NSString *error) {
            
            NSLog(@"错误：%@",error);
            
        }];
    }
    else if (getBtn.tag == 103){
        [HttpClient post_Login_action:Url_Login withuid:@"111" withname:@"小明" success:^(id responseObject) {
            
            NSLog(@"请求的数据：%@",responseObject);
            
        } fail:^(NSString *error) {
            
            NSLog(@"错误：%@",error);
            
        }];
    }
}

@end
